import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  ModelList,
  ModelAdd,
  ModelUpdateAds,
  ModelPayment,
  modelImport,
} from "./types";

// 获取推广链接列表
export function promotionSearchList(
  data: ModelList
): AxiosPromise<Record<string, any>> {
  return request({
    url: "/api/Promotions/search",
    method: "get",
    params: data,
  });
}

// 删除 - 推广链接
export function promotionsDelete(
  data: number
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/${data}`,
    method: "delete",
  });
}

//  新增 - 推广链接
export function promotionsAdd(
  data: ModelAdd
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions`,
    method: "post",
    data,
  });
}

//  更新 - 推广链接
export function promotionsEdit(
  data: ModelAdd
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/${data.id}`,
    method: "put",
    data,
  });
}

//  添加推广链接 - 获取剧集选项
export function operasOptions(data: {}): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Operas/options`,
    method: "get",
    params: data,
  });
}

// 添加推广链接 - 通过id获取剧集
export function operasNums(data: number): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Operas/${data}`,
    method: "get",
  });
}

//  获取推广链接回传信息 - 推广链接
export function getAds(data: number): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/${data}/ads-feedback`,
    method: "get",
  });
}

//  设置推广链接回传信息 - 推广链接
export function setAds(
  data: ModelUpdateAds
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/${data.id}/ads-feedback`,
    method: "patch",
    params: { useDefault: data.useDefault },
    data,
  });
}

//  推广链接- 获取收费设置
export function getPayment(data: number): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/${data}/payment`,
    method: "get",
  });
}

//  推广链接- 更新收费设置
export function updatePayment(
  data: ModelPayment
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/${data.id}/payment`,
    method: "patch",
    data,
  });
}

//  推广链接-  导入
export function importExcel(
  data: modelImport
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/import`,
    method: "post",
    data,
  });
}

//  推广链接- 付费过的推广链接下拉列表
export function getPromotionsList(
  data: ModelList
): AxiosPromise<Record<string, any>> {
  return request({
    url: `/api/Promotions/paid/options`,
    method: "get",
    params: data,
  });
}
